<?php

/**
 * Kontrola form base class.
 *
 * @method Kontrola getObject() Returns the current form's model object
 *
 * @package    Rejestracja
 * @subpackage form
 * @author     Michał Sobczak (smichal88@gmail.com)
 */
abstract class BaseKontrolaForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'idKontrola' => new sfWidgetFormInputHidden(),
      'data'       => new sfWidgetFormDate(),
      'idWizyta'   => new sfWidgetFormPropelChoice(array('model' => 'Wizyta', 'add_empty' => false)),
      'idPacjent'  => new sfWidgetFormPropelChoice(array('model' => 'Pacjent', 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'idKontrola' => new sfValidatorChoice(array('choices' => array($this->getObject()->getIdkontrola()), 'empty_value' => $this->getObject()->getIdkontrola(), 'required' => false)),
      'data'       => new sfValidatorDate(array('required' => false)),
      'idWizyta'   => new sfValidatorPropelChoice(array('model' => 'Wizyta', 'column' => 'idWizyta')),
      'idPacjent'  => new sfValidatorPropelChoice(array('model' => 'Pacjent', 'column' => 'idPacjent')),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorPropelUnique(array('model' => 'Kontrola', 'column' => array('idWizyta')))
    );

    $this->widgetSchema->setNameFormat('kontrola[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Kontrola';
  }


}
